package com.itheima.putige.putige.controller;

import com.itheima.putige.putige.utils.BrowserUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Copyright (C), 2021-2022
 * Author: 16372
 * Date: 2022/3/1 19:53
 * FileName: ViewController
 * Description: 登录页导航
 */
@RestController
public class ViewController {
    @GetMapping("/")
    public void index(HttpServletRequest request, HttpServletResponse resp) throws IOException {
        String userAgent = request.getHeader("user-agent");
        boolean mobile = BrowserUtils.isMobile(userAgent);
        if (mobile) {
            resp.sendRedirect("/front/page/login.html");
            return;
        } else {
            resp.sendRedirect("/backend/page/login/login.html");
            //resp.sendRedirect("/backend/index.html");
        }
    }
}
